package com.wangzh.nio.chars;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class CharDemo {

    public static void main(String[] args) throws UnsupportedEncodingException {
        String str = "ai你哟";

//        编码
        byte[] bytes = str.getBytes();
        System.out.println(Arrays.toString(bytes));

        byte[] bytes1 = str.getBytes("GBK");
        System.out.println(Arrays.toString(bytes1));

//        解码
        String str2 = new String(bytes1,"GBK");
        System.out.println(str2);
    }
}
